﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DirectX.Capture;

namespace CurlCam
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Capture capture = null;
        public MainWindow()
        {
            InitializeComponent();
            this.SourceInitialized += new EventHandler(MainWindow_SourceInitialized);
        }

        void MainWindow_SourceInitialized(object sender, EventArgs e)
        {
            Filters filters = new Filters();
            capture = new Capture(filters.VideoInputDevices["USB 2.0 Camera"], null);
            capture.VideoCompressor = filters.VideoCompressors["DV Video Encoder"];

            //capture.PreviewWindow = new UIElementHandle(MediaHost);
        }

        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            capture.Filename = @"C:\capture\" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".avi";
            capture.Start();
        }

        private void StopButton_Click(object sender, RoutedEventArgs e)
        {
            capture.Stop();
        }
    }
}
